package com.yyt.module_main.fragment;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseViewHolder;
import com.yanzhenjie.recyclerview.swipe.widget.DefaultItemDecoration;
import com.yyt.libsrc.bean.PresentRecordBean;
import com.yyt.libsrc.conf.Consts;
import com.yyt.libsrc.net.JavaParamsBuilder;
import com.yyt.libsrc.net.NetUtil;
import com.yyt.libsrc.net.SuccessCallback;
import com.yyt.libsrc.router.RouteTable;
import com.yyt.libsrc.router.RouterHelper;
import com.yyt.module_main.R;

import top.lixb.libcommon.base.RefreshListFragment;
import top.lixb.libcommon.utils.StringUtils;

public class WithdrawOrderFragment extends RefreshListFragment<PresentRecordBean.DataBean.ListBean> {

    @Override
    protected void getData(boolean refresh) {
        NetUtil.sellerPost(new JavaParamsBuilder()
                .addCmd(Consts.CMD.presentRecord)
                .addP("status", "")//状态1.审核中2.提现成功3.提现失败（不传查全部）
//                .addP("type", "2") //类型1.奖励2.分红
//                .addP("startTime", String.valueOf(0L))
//                .addP("endTime", String.valueOf(9999999999999L))
                .addP("showCount", String.valueOf(mPageSize))
                .addP("currentPage", String.valueOf(mPage))
                .build(), new SuccessCallback<PresentRecordBean>() {
            @Override
            public void onSuccess(PresentRecordBean presentRecordBean) {
                setData(presentRecordBean.data.list);
            }
        });
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        mSrl.setEnableLoadMore(true);
    }

    @Override
    protected int getItemLayout() {
        return R.layout.item_withdraw_order;
    }

    @Override
    protected void bind(BaseViewHolder holder, final PresentRecordBean.DataBean.ListBean item) {
        holder.setText(R.id.tv_amount, StringUtils.doubleFormat(String.valueOf(item.amount)));
        holder.setText(R.id.tv_date, item.createTime);
        holder.getView(R.id.tv_trace).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString("reqSn",item.req_sn);
                RouterHelper.getInstance().startAct(RouteTable.main_order_trace,bundle);
            }
        });
    }
}
